<?php include 'conf/base.php';?>

<?php $title = gettext("Perfil Usuario") ." " . $_GET['username']. " | ". gettext("Anuncios Locales")?>
<?php $descripcion = gettext("Perfil Usuario") . " " . $_GET['username']?>
<?php $keywords = gettext("Perfil Usuario") . " " . $_GET['username']?>

<?php include 'template_header_subdominios.php'?>
<?php include 'template_nav_bar_subdominios.php';?>
<?php include 'template/recurso_zebra_pagination_css.php'?>

<?php 

	$usuarioId = $_GET['usuarioId'];
	$username = $_GET['username'];
	
	$estadisticas = get_estadisticas($usuarioId);
	$usuario = get_valores_usuario($usuarioId, array("username"));
		
	// how many records should be displayed on a page?
	$records_per_page = 4;

	// include the pagination class
	require 'zebra-pagination/Zebra_Pagination.php';

	// instantiate the pagination object
	$pagination = new Zebra_Pagination();

	$sql = buscar_por_usuario($usuarioId, $pagination, $records_per_page);

	// if query could not be executed
	if (!($result = @mysql_query($sql))) {

		// stop execution and display error message
		die(mysql_error());

	}

	// fetch the total number of records in the table
	$rows = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() AS rows'));

	// pass the total number of records to the pagination class
	$pagination->records($rows['rows']);

	// records per page
	$pagination->records_per_page($records_per_page);


	$result = mysql_query($sql);
?>

<?php 

 if (empty($usuario)){?>
 	
 	<div class="container">
		<div class="row">
			<div class="col-md-12">
			 <br> 	
			 <div class="alert alert-danger"><?php echo gettext("Usuario no encontrado")?></div>		
			 
			   <section>
                    <form role="form" id="center-form" method="get" action="<?php echo get_busqueda_url()?>">
                        <div class="form-group">
                            <input class="form-control input-lg" type="text" name="query" id="query" placeholder="<?php echo gettext("buscar aquí")?>">
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-ar btn-block btn-lg btn-success"><?php echo gettext("Buscar")?></button>
                        </div>
                    </form>
                </section>
			 	 			  
			</div>
		</div>
	</div>
 	
 <?php } else {

?>

<div class="container">
<div class="row">
	<div class="col-md-12">
	
	<section class="margin-top">
       <p class="slogan text-center"><span><strong>
        <?php echo gettext("Anuncios de")?> <?php echo $usuario['username']; if (MODULO_PREMIUM && is_usuario_publicacion_premium($usuarioId)){?> <i class="fa fa-star yelow"></i><i class="fa fa-star yelow"></i><i class="fa fa-star yelow"></i><i class="fa fa-star yelow"></i><i class="fa fa-star yelow"></i> <?php }?>
		</strong></span></p>
   </section>
   
   <section>
   
   <?php include 'adsense_perfil_arriba.php';?>
   
   </section>
   
   <section class="margin-bottom">
   	
	    <?php 
		while ($publicacion = mysql_fetch_array($result)){
			$encontro = true;
			$imagen_path = get_image_thumb_path($publicacion['publicacion_id']);
			$imagenTipoUsuario = getPathImagenTipoUsuario($publicacion['usuario_id']);
			$publicacionId = $publicacion['publicacion_id'];
			$ciudad = get_valores_ciudad($publicacion['ciudad_id'], array("nombre"));	
			$alt = clean_string_with_spaces($publicacion['titulo']);	
			$publicacionPath =  getPublicacionPath($publicacionId);
		
		?>
				<div class="col-md-6">	
				  <?php include 'content_box_default_list.php';?>
			   	</div>   
		<?php }?>	   		
	
	<div class="col-md-12 text-center">
	 <?php include 'adsense_perfil_abajo.php';?>
	<?php $pagination->render();?>
	</div>	
   
   	</section>
   
   </div>
   
   
    <section class="margin-top">
        <p class="lead lead-lg text-center primary-color margin-bottom"><strong><?php echo gettext("Anuncios Clasificados Gratis en")?> <?php echo PAIS?></strong></p>
   </section>
   
 </div> 
   
</div>

<?php }?>

<?php include 'template_footer_subdominios.php'?>
<?php include 'template_side_bar_subdominios.php';?>

<!-- Scripts -->
<!-- Compiled in vendors.js -->
<!--
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-switch.min.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/slidebars.min.js"></script>
<script src="assets/js/jquery.bxslider.min.js"></script>
<script src="assets/js/holder.js"></script>
<script src="assets/js/buttons.js"></script>
<script src="assets/js/jquery.mixitup.min.js"></script>
<script src="assets/js/circles.min.js"></script>
<script src="assets/js/masonry.pkgd.min.js"></script>
<script src="assets/js/jquery.matchHeight-min.js"></script>
-->

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/vendors.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/funcionesjs.js"></script>

<!-- Syntaxhighlighter -->
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shCore.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushXml.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushJScript.js"></script>

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/app.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/index.js"></script>

</body>

</html>